package cn.ryh.listener.interfaceiml.config;

import cn.ryh.listener.interfaceiml.InterfaceServletContextListener;
import cn.ryh.listener.interfaceiml.InterfaceSessionListener;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

/**
 * @author Rao
 * @Description
 * @create 2022-04-15 17:12
 */
@Configuration
public class InterfaceConfig implements ServletContextInitializer {

    /**
     * 通过实现ServletContextInitializer接口，重写其onStartup()方法
     * 来注册servlet
     *
     * @param servletContext
     * @throws ServletException
     */
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        //创建Listener
        servletContext.addListener(new InterfaceServletContextListener());
        servletContext.addListener(new InterfaceSessionListener());
    }
}
